version 10.1

	/************************************************/
	/* Get starting values with two Weibull models.	*/
	/************************************************/

	
program define warofatt_sv, rclass

  syntax, tstar(real) depvar(varlist) [indvars(varlist) probss(varlist)]

	tempname _b0 _b0_W _b0_SS _b0_W_lnp _b0_SS_lnp _b0pi
	
	preserve

	quietly stset `depvar' if `depvar' > `tstar', enter(time `tstar')

	  capture streg, dist(weibull) nohr
	  
	  if _rc == 0 {
		matrix `_b0_SS' = e(b)
		}
		
	  else {

		capture streg, dist(exponential) nohr
	  
		if _rc == 0 {
		  di "Going to Exponential for Strong-Strong equation starting values."
		  matrix `_b0_SS' = (_b[_cons], 0)
		  }

		else {
		  matrix `_b0_SS' = (0, 0)
		  }

		}

	quietly stset `depvar' if `depvar' <= `tstar', exit(time `tstar')

	  capture streg `indvars', dist(weibull) nohr
	  
	  if _rc == 0 {
		matrix `_b0_W' = e(b)
		}
		
	  else {
		matrix `_b0_W' = J(1,`=wordcount("`indvars'")+2',0)
		}
		

	matrix `_b0_SS_lnp' = `_b0_SS'[1,colsof(`_b0_SS')]
	matrix `_b0_SS' = `_b0_SS'[1,1..`=colsof(`_b0_SS')-1']

	matrix `_b0_W_lnp' = `_b0_W'[1,colsof(`_b0_W')]
	matrix `_b0_W' = `_b0_W'[1,1..`=colsof(`_b0_W')-1']

	matrix `_b0pi' = J(1,`=wordcount("`probss'")+1',0)

	matrix `_b0' = `_b0_W' , `_b0_SS' , `_b0pi' , `_b0_W_lnp' , `_b0_SS_lnp'

	return matrix b0 = `_b0'
	
	restore
	
end
